/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.pe.siass.bussines;

import com.pe.siass.beans.ActorBean;
import com.pe.siass.beans.CasosBean;
import com.pe.siass.beans.ParametrosBean;
import com.pe.siass.dao.ActorDao;
import com.pe.siass.dao.CasosDao;
import com.pe.siass.dao.ParametroDao;
import com.pe.siass.utils.USqlMapLoader;
import java.io.IOException;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

/**
 *
 * @author Hrengifo
 */
public class ActualizarDaoImplm {
    
   private SqlSessionFactory sqlSessionFactory = null;
   ActorDao actorDao = new ActorDao();
   CasosDao casosDao = new CasosDao();
   ParametroDao parametroDao = new ParametroDao();

   public ActualizarDaoImplm() throws IOException {
        sqlSessionFactory =  USqlMapLoader.getInstance().getSession();
    }

   public int updateCasos(ActorBean actorBean){
       SqlSession sqlSession = sqlSessionFactory.openSession();
       int aux = -1;
       try{
           aux = actorDao.updateActor(actorBean, sqlSession);
        }catch(Exception e){
           e.printStackTrace();
           aux = -1;
           sqlSession.rollback();
        }
        finally{
            sqlSession.commit();
            sqlSession.close();
        }
        return aux;
   }

   public int updateCasos(CasosBean casosBean){
       SqlSession sqlSession = sqlSessionFactory.openSession();
       int aux = -1;
       try{
           aux = casosDao.updateCasos(casosBean, sqlSession);
        }catch(Exception e){
           e.printStackTrace();
           aux = -1;
           sqlSession.rollback();
        }
        finally{
            sqlSession.commit();
            sqlSession.close();
        }
        return aux;
    }

    public int updateParametros(ParametrosBean parametrosBean){
       SqlSession sqlSession = sqlSessionFactory.openSession();
       int aux = -1;
       try{
           aux = parametroDao.updateParametros(parametrosBean, sqlSession);
        }catch(Exception e){
           e.printStackTrace();
           aux = -1;
           sqlSession.rollback();
        }
        finally{
            sqlSession.commit();
            sqlSession.close();
        }
        return aux;
    }



}
